/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Heart.java
 *
 * Created on Jun 11, 2011, 9:18:48 PM
 */
package Game;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.util.Timer;

/**
 *
 * @author NGUYEN VAN TAM
 */
public class Heart extends javax.swing.JFrame {

    /** Creates new form Heart */
    public Heart() {
        initComponents();
        //setMaximumSize(new Dimension(1024,768));//Toolkit.getDefaultToolkit().getScreenSize()
        
        //this.validate();
        Rectangle maxBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().
        getMaximumWindowBounds();

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        
        //this.setMaximumSize(new Dimension(maxBounds.width, 200));
        //this.setMinimumSize(new Dimension(screenSize.width, screenSize.height));
        this.setSize(maxBounds.width, maxBounds.height);
        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        
        InitGame();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Hearts");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setIconImages(null);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 465, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 308, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Heart heart = new Heart();
                heart.setVisible(true);
                //heart.game.GameLoop(gameTime, graphic);
                //Heart.game.Draw(gameTime, graphic);
            }
        });
    }
    public static Timer gameTime;
    public static Graphics2D graphic;
    public static Game game;
    
    private void InitGame()
    {
        gameTime = new Timer();
        graphic = (Graphics2D)this.getGraphics();
        game = new Game();
        game.Init();
        game.LoadContent();
    }
    
    public static void Update()
    {
        game.Update(gameTime);
    }
    
    public static void Draw()
    {
        game.Draw(gameTime, graphic);
    }
    
    @Override
    public void paint(Graphics g) {
    //super.paint();
    // paint line here
    //this.jMenuBar1.paint(graphic);
    //this.jMenuBar1.repaint();
    game.Draw(gameTime, graphic);
    //this.jMenuBar1.paint(graphic);
  }

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
